#! /bin/bash
echo "pull code..."
cd /root/code/mate-cloud/
git pull
echo "maven clean install..."
mvn clean install -Dmaven.javadoc.skip=true -Dgpg.skip

######杀死进程
echo "kill process..."

kill -9 `cat /usr/local/deploy/mate-cloud/jar/mate-gateway.pid`
kill -9 `cat /usr/local/deploy/mate-cloud/jar/mate-uaa.pid`
kill -9 `cat /usr/local/deploy/mate-cloud/jar/mate-system.pid`
kill -9 `cat /usr/local/deploy/mate-cloud/jar/mate-component.pid`


######关闭项目
sh /usr/local/deploy/mate-cloud/mate-gateway.sh stop
echo "stop mate-gateway"
sh /usr/local/deploy/mate-cloud/mate-uaa.sh stop
echo "stop mate-uaa"
sh /usr/local/deploy/mate-cloud/mate-system.sh stop
echo "stop mate-system"
sh /usr/local/deploy/mate-cloud/mate-component.sh stop
echo "stop mate-component"

mkdir -p /usr/local/deploy/mate-cloud/jar/


######copy文件/备份原文件

echo "copy files..."
rm -rf /usr/local/deploy/mate-cloud/jar/mate-gateway.jar
rm -rf /usr/local/deploy/mate-cloud/jar/mate-uaa.jar
rm -rf /usr/local/deploy/mate-cloud/jar/mate-system.jar
rm -rf /usr/local/deploy/mate-cloud/jar/mate-component.jar


cp -f /root/code/mate-cloud/mate-gateway/target/mate-gateway.jar  /usr/local/deploy/mate-cloud/jar/mate-gateway.jar
cp -f /root/code/mate-cloud/mate-uaa/target/mate-uaa.jar  /usr/local/deploy/mate-cloud/jar/mate-uaa.jar
cp -f /root/code/mate-cloud/mate-platform/mate-system/target/mate-system.jar  /usr/local/deploy/mate-cloud/jar/mate-system.jar
cp -f /root/code/mate-cloud/mate-platform/mate-component/target/mate-component.jar  /usr/local/deploy/mate-cloud/jar/mate-component.jar


######日志
echo "init log files"
mkdir -p  /usr/local/deploy/mate-cloud/logs

# rm -rf /usr/local/deploy/mate-cloud/logs/*.out*


######启动脚本
sh /usr/local/deploy/mate-cloud/mate-gateway.sh start
sh /usr/local/deploy/mate-cloud/mate-uaa.sh start
sh /usr/local/deploy/mate-cloud/mate-system.sh start
sh /usr/local/deploy/mate-cloud/mate-component.sh start


echo "start mate-cloud"



